package example
{
	import example.globals.Assets;
	import example.ogmoProjects.ExampleProject;
	import flash.display.Sprite;
	import flash.events.Event;
	import maskedpixel.ogmo.*;
	import maskedpixel.ogmo.utils.*;
	import net.flashpunk.World;
	
	import net.flashpunk.Engine;
	import net.flashpunk.FP;
	
	/**
	 * ...
	 * @author MaskedPixel
	 */
	public class Main extends Engine
	{
		/**
		 * Constructor...
		 */
		public function Main()
		{
			super(648, 480, 60, false);
		}
		
		/**
		 * @inheritDoc
		 */
		override public function init():void
		{
			FP.console.enable();
			trace("Begin tests");
			trace("..........................................................");
			trace("Test: Creating a project.");
			createProject();
			
			trace("...........................................................");
			trace("Test: Load a Level.");
			loadLevel();
		}
		
		/**
		 * Creates the example project included with the Ogmo Editor.  Mostly.
		 */
		private function createProject():void 
		{
			// init the Ogmo Example project and register it with the static OgmoProject.
			var exampleProject:OgmoProject = new ExampleProject();
			exampleProject.registration();
			
			// generate the project file.
			OgmoProject.generateProject();
			trace("COMPLETE: Creating a project.");
		}
		
		/**
		 * Loads a a level, creates a world, and adds the entities.
		 */
		private function loadLevel():void
		{
			var world:World = new World();
			var exampleProject:ExampleProject = new ExampleProject();
			exampleProject.registration();
			
			var level:OgmoLevel = OgmoLevel.loadLevel(new Assets.LEVEL1());
			
			world.addList(level.entityList);
			
			FP.world = world;
			trace("COMPLETE: Load a level.");
		}
	}
	
}